summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-02-18 16:24:58 +0100
committerGitHub <noreply@github.com>2024-02-18 16:24:58 +0100
commitf57281ebc13669472d7a085df2c8f7e94050db68 (patch)
tree1a273d95c802fad3d7c467a20292eca1984fa2e9
parentMerge pull request #13047 from anpilley/import-firmware (diff)
parentandroid: Map touches to touchscreen (diff)
downloadyuzu-f57281ebc13669472d7a085df2c8f7e94050db68.tar
yuzu-f57281ebc13669472d7a085df2c8f7e94050db68.tar.gz
yuzu-f57281ebc13669472d7a085df2c8f7e94050db68.tar.bz2
yuzu-f57281ebc13669472d7a085df2c8f7e94050db68.tar.lz
yuzu-f57281ebc13669472d7a085df2c8f7e94050db68.tar.xz
yuzu-f57281ebc13669472d7a085df2c8f7e94050db68.tar.zst
yuzu-f57281ebc13669472d7a085df2c8f7e94050db68.zip
-rw-r--r--src/android/app/src/main/jni/emu_window/emu_window.cpp16
-rw-r--r--src/android/app/src/main/jni/emu_window/emu_window.h4
-rw-r--r--src/android/app/src/main/jni/native_input.cpp8
3 files changed, 23 insertions, 5 deletions
diff --git a/src/android/app/src/main/jni/emu_window/emu_window.cpp b/src/android/app/src/main/jni/emu_window/emu_window.cpp
index 2768a01c9..06db55369 100644
--- a/src/android/app/src/main/jni/emu_window/emu_window.cpp
+++ b/src/android/app/src/main/jni/emu_window/emu_window.cpp
@@ -23,6 +23,22 @@ void EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) {
window_info.render_surface = reinterpret_cast<void*>(surface);
}
+void EmuWindow_Android::OnTouchPressed(int id, float x, float y) {
+ const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
+ EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchPressed(touch_x,
+ touch_y, id);
+}
+
+void EmuWindow_Android::OnTouchMoved(int id, float x, float y) {
+ const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
+ EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchMoved(touch_x,
+ touch_y, id);
+}
+
+void EmuWindow_Android::OnTouchReleased(int id) {
+ EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchReleased(id);
+}
+
void EmuWindow_Android::OnFrameDisplayed() {
if (!m_first_frame) {
Common::Android::RunJNIOnFiber<void>(
diff --git a/src/android/app/src/main/jni/emu_window/emu_window.h b/src/android/app/src/main/jni/emu_window/emu_window.h
index 34704ae95..d7b5fc6da 100644
--- a/src/android/app/src/main/jni/emu_window/emu_window.h
+++ b/src/android/app/src/main/jni/emu_window/emu_window.h
@@ -38,6 +38,10 @@ public:
void OnSurfaceChanged(ANativeWindow* surface);
void OnFrameDisplayed() override;
+ void OnTouchPressed(int id, float x, float y);
+ void OnTouchMoved(int id, float x, float y);
+ void OnTouchReleased(int id);
+
std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override {
return {std::make_unique<GraphicsContext_Android>(m_driver_library)};
}
diff --git a/src/android/app/src/main/jni/native_input.cpp b/src/android/app/src/main/jni/native_input.cpp
index ddf2f297b..37a65f2b8 100644
--- a/src/android/app/src/main/jni/native_input.cpp
+++ b/src/android/app/src/main/jni/native_input.cpp
@@ -190,8 +190,7 @@ void Java_org_yuzu_yuzu_1emu_features_input_NativeInput_onTouchPressed(JNIEnv* e
jint j_id, jfloat j_x_axis,
jfloat j_y_axis) {
if (EmulationSession::GetInstance().IsRunning()) {
- EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchPressed(
- j_id, j_x_axis, j_y_axis);
+ EmulationSession::GetInstance().Window().OnTouchPressed(j_id, j_x_axis, j_y_axis);
}
}
@@ -199,15 +198,14 @@ void Java_org_yuzu_yuzu_1emu_features_input_NativeInput_onTouchMoved(JNIEnv* env
jint j_id, jfloat j_x_axis,
jfloat j_y_axis) {
if (EmulationSession::GetInstance().IsRunning()) {
- EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchMoved(
- j_id, j_x_axis, j_y_axis);
+ EmulationSession::GetInstance().Window().OnTouchMoved(j_id, j_x_axis, j_y_axis);
}
}
void Java_org_yuzu_yuzu_1emu_features_input_NativeInput_onTouchReleased(JNIEnv* env, jobject j_obj,
jint j_id) {
if (EmulationSession::GetInstance().IsRunning()) {
- EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchReleased(j_id);
+ EmulationSession::GetInstance().Window().OnTouchReleased(j_id);
}
}